import request from '@/utils/request'

export default {
  getAttractionList(searchModel) {
    let params = '&pageNo=' + searchModel.pageNo + '&pageSize=' + searchModel.pageSize
    params =
      searchModel.name === '' ||
      searchModel.name === null ||
      searchModel.name === undefined
        ? params
        : params + '&name=' + searchModel.name
    params =
      searchModel.type === '' ||
      searchModel.type === null ||
      searchModel.type === undefined
        ? params
        : params + '&type=' + searchModel.type
    return request({
      url: '/attraction/list?' + params,
      method: 'get'

      // params:{
      //   pageNo:searchModel.pageNo,
      //   pageSize:searchModel.pageSize,
      //   name:searchModel.name,
      //   type:searchModel.type
      // }
    })
  },
  addAttraction(attraction) {
    return request({
      url: '/attraction/addAttraction',
      method: 'post',
      data: attraction
    })
  },
  updateAttraction(attraction) {
    return request({
      url: '/attraction/updateAttraction',
      // method: 'put',
      method: 'post',
      data: attraction
    })
  },
  saveAttraction(attraction) {
    if (attraction.attractionId == null || attraction.attractionId === undefined) {
      return this.addAttraction(attraction)
    }
    return this.updateAttraction(attraction)
  },
  getAttractionById(attractionId) {
    return request({
      // url: '/attraction/'+id,
      url: `/attraction/getAttractionById/${attractionId}`,
      method: 'get'
    })
  },
  deleteById(attractionId) {
    return request({
      url: `/attraction/deleteAttractionById`,
      method: 'delete',
      params: {
        deleteAttractionId: attractionId
      }
    })
  }

}
